package com.jade.bss.admin.grant;

import java.io.Serializable;
import javax.persistence.*;

import com.jade.bss.admin.permission.PermissionEntry;

/**
 * GrantEntry代表身份和权限之间的关联.身份包括用户、角色等等。
 *
 * @author sky
 * @version 1.0 13-4-18 上午9:40
 */
@Entity
@Table (name = "BSS_GRANT")
public class GrantEntry implements Serializable
{
    public static final String ENTRY_TYPE_ROLE = "role";
    public static final String ENTRY_TYPE_PERM = "perm";

    @Id
    @GeneratedValue (generator = "BSS_SEQ_GRANT")
    @SequenceGenerator (name = "BSS_SEQ_GRANT", sequenceName = "BSS_SEQ_GRANT")
    private int id;

    /** 身份类型 */
    @Column (name = "principal_type", nullable = false, length = 16)
    private String principalType;

    /** 身份名称 */
    @Column (name = "principal_name", nullable = false, length = 32)
    private String principalName;

    /** 可以被授权给Principal的实体类型，权限或者角色*/
    @Column (name = "entry_type", nullable = false, length = 32)
    private String entryType;

    /** 权限或者角色标识 */
    @Column (name = "entry_id", nullable = false, length = 32)
    private int entryId;
//    /** 权限实体 */
//    @ManyToOne
//    @JoinColumn (name = "permission_id")
//    private PermissionEntry permission;

    /** scheme标识, 目前先不实现 */
    //@ManyToOne
    //@JoinColumn (name = "scheme_id")
    //private SecurityScheme scheme;
    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    public String getPrincipalType()
    {
        return principalType;
    }

    public void setPrincipalType(String principalType)
    {
        this.principalType = principalType;
    }

    public String getPrincipalName()
    {
        return principalName;
    }

    public void setPrincipalName(String principalName)
    {
        this.principalName = principalName;
    }

    public String getEntryType()
    {
        return entryType;
    }

    public void setEntryType(String entryType)
    {
        this.entryType = entryType;
    }

    public int getEntryId()
    {
        return entryId;
    }

    public void setEntryId(int entryId)
    {
        this.entryId = entryId;
    }

    //    public PermissionEntry getPermission()
    //    {
    //        return permission;
    //    }
    //
    //    public void setPermission(PermissionEntry permission)
    //    {
    //        this.permission = permission;
    //    }
}
